//
//  Area.m
//  UI省市区
//
//  Created by GivenBmli on 16/7/26.
//  Copyright © 2016年 GivenBmli. All rights reserved.
//

#import "Area.h"
#define kTruse @"reuse"
@interface Area ()<UITableViewDataSource , UITableViewDelegate>
@property (nonatomic , strong)UITableView *tableView;
@property (nonatomic , strong)NSMutableArray <NSArray *>*areaArray;
@end

@implementation Area

- (void)viewDidLoad {
    [super viewDidLoad];
    NSString *cityName = _cityDic[@"市名"];
    NSArray *tempArr = [cityName componentsSeparatedByString:@" "];
    self.navigationItem.title = tempArr[2];
    self.tableView = [[UITableView alloc] initWithFrame:[UIScreen mainScreen].bounds style:UITableViewStylePlain];
    self.tableView.delegate = self;
    self.tableView.dataSource = self;
    _areaArray = [NSMutableArray array];
    _areaArray = _cityDic[@"区组"];
    [self.view addSubview:_tableView];
    [_tableView registerClass:[UITableViewCell class] forCellReuseIdentifier:kTruse];
}



- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return _areaArray.count;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:kTruse];
    if (!cell) {
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:kTruse];
    }
    NSString *cityName = _areaArray[indexPath.row];
    NSArray *tempArr = [cityName componentsSeparatedByString:@" "];
    NSLog(@"%@",tempArr);
    cell.textLabel.text = tempArr[4];
    cell.detailTextLabel.text = [tempArr lastObject];
    cell.backgroundColor = [UIColor whiteColor];
    return cell;

    
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}



@end
